class Main extends egret.Sprite {

    private _lastTime: number;


    public yidong() {

        var self = this;
        var url: string = "resource/ditu.tmx";
        var urlLoader: egret.URLLoader = new egret.URLLoader();

        var classa= RES.getRes("ditu_json");
              console.log(classa.layers); 
        urlLoader.dataFormat = egret.URLLoaderDataFormat.TEXT;
        //load complete
        //   var nowTime: number = egret.getTimer();
        // var fps: number = 1000 / (nowTime - (this._lastTime));
        // this._lastTime = nowTime;
        // var speedOffset: number = 60 / fps;
        urlLoader.addEventListener(egret.Event.COMPLETE, function (event: egret.Event): void {
            var data: any = egret.XML.parse(event.target.data);
            var tmxTileMap: tiled.TMXTilemap = new tiled.TMXTilemap(2000, 2000, data, this);
            // tmxTileMap.x=200;
            // tmxTileMap.render();
            var arr: any = tmxTileMap.getObjects();
            //得到当前层级对象info
            var objData: any = arr[0]._childrens[0];
            //得到当前对象
            var currentObj: egret.DisplayObject = objData.attributes
            document.addEventListener("keypress", e => {
                if (e.key == "w")
                { currentObj.y -= 200; }
            })
            for (var key in currentObj) {
                console.log(key + ":" + currentObj[key]);
            }
            self.addChild(tmxTileMap);
        }, url);
        urlLoader.load(new egret.URLRequest(url));

        this.removeEventListener(egret.Event.ENTER_FRAME, this.yidong, this);

    }
}